package File;

import android.os.Environment;

import java.io.File;
import java.io.IOException;

/**
 * Created by zelonghu on 2018/4/17.
 * @TODO 用来管理SD卡的相关存储
 * @LASTEDIT 2018/4/17
 */

public class FileUtils {
    private String SDRootPATH;
    //得到目录地址
    public FileUtils(){
        SDRootPATH = Environment.getExternalStorageDirectory().getAbsolutePath();

    }
    /**
     * 在SD卡创建路径
     * */
    public File createfileOnSDcard(String dir, String filename)throws IOException {
        File file = new File( SDRootPATH+dir+File.separator+filename);
        System.out.println("file--->"+file);
        file.createNewFile();
        return file;
    }
    /**
     * 在SD卡创建目录
     * */
    public File createdir(String dirname)throws IOException{
        System.out.println("SDROOTpath-->"+SDRootPATH + File.separator +dirname+File.separator);

        File dir = new File(SDRootPATH + File.separator +dirname+File.separator );

        System.out.println("mkdir-->"+dir.mkdirs());
        return  dir;
    }
    /**
     * 判断文件是否存在
     **/
    public Boolean isexist(String dirname,String name){

        File file = new File(SDRootPATH + File.separator+ dirname + File.separator + name);
        return (file.exists());

    }
    public Boolean isexist(String dirname){

        File file = new File(SDRootPATH +File.separator+ dirname + File.separator);
        return (file.exists());

    }



}
